import torch as pt
import numpy as np

a = pt.arange(12, dtype=pt.uint8).reshape(3, 4)
b = pt.arange(12, dtype=pt.float32).reshape(4, 3)
c = pt.arange(12, dtype=pt.long).reshape(2, 6)

print(a, a.dtype)
print(b, b.dtype)
print(c, c.dtype)

aa = np.random.randn(3, 4)
print(aa)
aa_np = np.array(aa, dtype=np.float32)
print(aa_np, aa_np.dtype)
aa_t = pt.Tensor(aa_np)  # ATTENTION Cannot specify dtype here.
print(aa_t, aa_t.dtype)

ones_t = pt.ones_like(aa_t, dtype=pt.uint8)
print(ones_t, ones_t.dtype)
ones_t = pt.ones_like(aa_t, dtype=pt.int64)
print(ones_t, ones_t.dtype)
ones_t = pt.ones_like(aa_t, dtype=pt.float32)
print(ones_t, ones_t.dtype)
ones_t = pt.ones_like(aa_t, dtype=pt.long)
print(ones_t, ones_t.dtype)
